Skip to content

fix(cli): lint with multiple api files results in invalid output#2744

Open
harshit078 wants to merge 6 commits intoRedocly:mainfrom
harshit078:fix-lint-multiple-files
Open

fix(cli): lint with multiple api files results in invalid output#2744
harshit078 wants to merge 6 commits intoRedocly:mainfrom
harshit078:fix-lint-multiple-files

Conversation

@harshit078
Copy link
Copy Markdown
Contributor

@harshit078 harshit078 commented Apr 15, 2026

What/Why/How?

  • Added logic to gather all lint results into allResults during per-file loop, then call formatProblems() once after with the combined totals.

Reference

#2692

Testing

Screenshots (optional)

Check yourself

  • This PR follows the contributing guide
  • All new/updated code is covered by tests
  • Core code changed? - Tested with other Redocly products (internal contributions only)
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update has been considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

Note

Medium Risk
Changes how lint emits formatted output by aggregating results across multiple API files and ensuring output is still emitted on partial failure, which could affect downstream tooling that parses CLI output.

Overview
Fixes multi-API lint runs for structured formats by accumulating all per-file lint problems and totals and calling formatProblems once to produce a single combined report (instead of emitting per-file documents).

Adds a try/finally so accumulated results are still output when later API linting fails, updates/extends unit tests for aggregation and partial-failure behavior, and updates docs plus a changeset to reflect the new combined structured output behavior.

Reviewed by Cursor Bugbot for commit 1799891. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

🦋 Changeset detected

Latest commit: 1799891

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@redocly/cli Patch
@redocly/openapi-core Patch
@redocly/respect-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@harshit078 harshit078 changed the title fix(cli): lint with multiple api files results in invalid checkstyle/json output fix(cli): lint with multiple api files results in invalid output Apr 15, 2026
@harshit078 harshit078 marked this pull request as ready for review April 15, 2026 12:24
@harshit078 harshit078 requested review from a team as code owners April 15, 2026 12:24
Comment thread packages/cli/src/commands/lint.ts
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1799891. Configure here.

maxProblems: argv['max-problems'],
totals,
version,
command: 'lint',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Markdown format shows misleading combined totals per file

Medium Severity

When multiple APIs are linted, the markdown format in formatProblems prints totals.errors and totals.warnings inside the per-file-group loop. Previously, formatProblems was called per-file with per-file fileTotals, so each section showed that file's counts. Now that it's called once with combined totals, every file section displays the same combined error/warning counts, making it look like each individual file has that many issues. This produces misleading markdown output.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1799891. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant